package com.ruoyi.net.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.uuid.IdUtils;
import com.ruoyi.net.domain.ElementBusiMtnclientFgVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.net.mapper.ElementBusiMtnclientFgMapper;
import com.ruoyi.net.domain.ElementBusiMtnclientFg;
import com.ruoyi.net.service.IElementBusiMtnclientFgService;

/**
 * 网元-业务-mtnclient-fgService业务层处理
 * 
 * @author net
 * @date 2024-11-17
 */
@Service
public class ElementBusiMtnclientFgServiceImpl implements IElementBusiMtnclientFgService 
{
    @Autowired
    private ElementBusiMtnclientFgMapper elementBusiMtnclientFgMapper;

    /**
     * 查询网元-业务-mtnclient-fg
     * 
     * @param id 网元-业务-mtnclient-fg主键
     * @return 网元-业务-mtnclient-fg
     */
    @Override
    public ElementBusiMtnclientFg selectElementBusiMtnclientFgById(String id)
    {
        return elementBusiMtnclientFgMapper.selectElementBusiMtnclientFgById(id);
    }

    /**
     * 查询网元-业务-mtnclient-fg列表
     * 
     * @param elementBusiMtnclientFg 网元-业务-mtnclient-fg
     * @return 网元-业务-mtnclient-fg
     */
    @Override
    public List<ElementBusiMtnclientFgVo> selectElementBusiMtnclientFgList(ElementBusiMtnclientFg elementBusiMtnclientFg)
    {
        List<ElementBusiMtnclientFgVo> elementBusiMtnclientFgs = elementBusiMtnclientFgMapper.selectElementBusiMtnclientFgList(elementBusiMtnclientFg);
        for (ElementBusiMtnclientFgVo fg: elementBusiMtnclientFgs) {
            if ("MTN1+1保护".equals(fg.getProtectType())){
                if ("3".equals(fg.getElementType())){
                    fg.setProtectType("无保护");
                }else{
                    fg.setProtectType("channel 1+1保护");
                }
            }
        }
        return elementBusiMtnclientFgs;
    }

    /**
     * 新增网元-业务-mtnclient-fg
     * 
     * @param elementBusiMtnclientFg 网元-业务-mtnclient-fg
     * @return 结果
     */
    @Override
    public int insertElementBusiMtnclientFg(ElementBusiMtnclientFg elementBusiMtnclientFg)
    {
        String uuid = IdUtils.simpleUUID();
        if (StringUtils.isEmpty(elementBusiMtnclientFg.getId())) {
            elementBusiMtnclientFg.setId(uuid);
        }
        elementBusiMtnclientFg.setCreateBy(SecurityUtils.getUsername());
        elementBusiMtnclientFg.setCreateTime(DateUtils.getNowDate());
        elementBusiMtnclientFg.setUpdateBy(SecurityUtils.getUsername());
        elementBusiMtnclientFg.setUpdateTime(DateUtils.getNowDate());
        return elementBusiMtnclientFgMapper.insertElementBusiMtnclientFg(elementBusiMtnclientFg);
    }

    /**
     * 修改网元-业务-mtnclient-fg
     * 
     * @param elementBusiMtnclientFg 网元-业务-mtnclient-fg
     * @return 结果
     */
    @Override
    public int updateElementBusiMtnclientFg(ElementBusiMtnclientFg elementBusiMtnclientFg)
    {
        elementBusiMtnclientFg.setUpdateBy(SecurityUtils.getUsername());
        elementBusiMtnclientFg.setUpdateTime(DateUtils.getNowDate());
        return elementBusiMtnclientFgMapper.updateElementBusiMtnclientFg(elementBusiMtnclientFg);
    }

    /**
     * 批量删除网元-业务-mtnclient-fg
     * 
     * @param ids 需要删除的网元-业务-mtnclient-fg主键
     * @return 结果
     */
    @Override
    public int deleteElementBusiMtnclientFgByIds(String[] ids)
    {
        return elementBusiMtnclientFgMapper.deleteElementBusiMtnclientFgByIds(ids);
    }

    /**
     * 删除网元-业务-mtnclient-fg信息
     * 
     * @param id 网元-业务-mtnclient-fg主键
     * @return 结果
     */
    @Override
    public int deleteElementBusiMtnclientFgById(String id)
    {
        return elementBusiMtnclientFgMapper.deleteElementBusiMtnclientFgById(id);
    }

    @Override
    public int updateElementBusiMtnclientFgStatusByEle(ElementBusiMtnclientFg elementBusiMtnclientFg) {
        return elementBusiMtnclientFgMapper.updateElementBusiMtnclientFgStatusByEle(elementBusiMtnclientFg);
    }
}
